
"""
This file is part of PeerTool, a web application for collaborative
decision-making (Copyrighted, 2009-2010, Ellis & Grant, Inc.)
Developed by Michael F. Ellis <michael.f.ellis@gmail.com>.  
License: AGPL v3
PeerTool comes with ABSOLUTELY NO WARRANTY.
"""                
import logging

def consoleLogger(name="app",level=logging.DEBUG):
    logger = logging.getLogger(name)

    if not hasattr(logger,"alreadyconfigured"):  ## needed for exec'd environments
        logger.propagate = False   ## prevent ancestors from getting messages
        logger.setLevel(level)
        # create console handler and set level to debug
        ch = logging.StreamHandler()
        ch.setLevel(level)
        # create formatter
        formatter = logging.Formatter("%(name)s:%(module)s.%(funcName)s: %(message)s")
        # add formatter to ch
        ch.setFormatter(formatter)
        # add ch to logger
        logger.addHandler(ch)
        logger.alreadyconfigured = True 

    return logger
    
